<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" type="text/css" href="../../css/public.css"/>
		<style type="text/css">
			#carousel img {
				max-width: 100%;
				width: auto;
				height: auto;
			}
		</style>
	</head>
	<body>
		<div id="carousel" class="layui-carousel" style="margin: auto;">
			<div carousel-item style="text-align: center;">
				<img src="../../images/userface5.jpg">
				<img src="../../images/userface1.jpg">
				<img src="../../images/userface2.jpg">
				<img src="../../images/userface3.jpg">
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		var ins;
		layui.use(['carousel', 'form'], function() {
			var carousel = layui.carousel,
				$ = layui.jquery;
			
			var imgHeight=$('#carousel img').height();
			var imgWidth=$('#carousel img').width();
			
			console.log(imgHeight)
			ins = carousel.render({
				elem: '#carousel',
				width:imgWidth,
				height:imgHeight,
				autoplay: false,
				arrow: 'none' 
			});

			$("#carousel").on("touchstart", function(e) {
				var startX = e.originalEvent.targetTouches[0].pageX; 
				$(this).on('touchmove', function(e) {
					arguments[0].preventDefault(); 
				});
				$(this).on('touchend', function(e) {
					var endX = e.originalEvent.changedTouches[0].pageX; 
					e.stopPropagation(); 
					if (endX - startX > 30) {
						ins.slide("sub");
					} else if (startX - endX > 30) {
						ins.slide("add");
					}
					$(this).off('touchmove touchend');
				});
			});

		});
	</script>
</html>
